package cn.edu.gzmtu.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtils {

    /**
     * 将日期转换成字符串
     * @param date
     * @param patt
     * @return
     */
    public static String dataToString(Date date, String patt){
        SimpleDateFormat simple = new SimpleDateFormat(patt);
        return simple.format(date);
    }

    /**
     * 字符串转换成日期
     * @param date
     * @param patt
     * @return
     * @throws ParseException
     */
    public static Date stringToDate(String date, String patt) throws ParseException {
        SimpleDateFormat simple =  new SimpleDateFormat(patt);
        return simple.parse(date);
    }
}
